package logic

import (
	"context"
	"wechat/models/mysql"

	"wechat/wechatrpc/internal/svc"
	"wechat/wechatrpc/wechatrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MomentsShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMomentsShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MomentsShowLogic {
	return &MomentsShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MomentsShowLogic) MomentsShow(in *wechatrpc.MomentsShowRequest) (*wechatrpc.MomentsShowResponse, error) {
	// todo: add your logic here and delete this line

	var user mysql.User

	if err := user.FindUserById(mysql.DB, in.UserId); err != nil {
		return nil, err
	}

	var moment mysql.Moments

	if err := moment.MomentShow(mysql.DB, in.MomentId); err != nil {
		return nil, err
	}

	return &wechatrpc.MomentsShowResponse{
		Image:   moment.Image,
		Article: moment.Article,
	}, nil
}
